
Page({
    data: {
        isShowHeading: true,
        msg: "Hello 小程序！",
        list: [
            { id: 11, text: "吃饭" },
            { id: 21, text: "睡觉" },
            { id: 13, text: "打豆豆" },
        ],
        itemText: '',
        type: '48'
    },
    handleToggle() {
        this.setData({
            isShowHeading: !this.data.isShowHeading
        })
    },
    handleGet() {
        // 获取data
        console.log(this.data.msg)
    },
    handleSet() {
        // x：this.data.msg = 'msg已修改'
        // 修改data
        this.setData({
            // msg: 'msg已修改'
            msg: this.data.msg.split('').reverse().join('')
        })
        console.log(this.data.msg)
    },
    handleSubmit() {
        console.log(this.data.itemText)
        return;
        if (!this.data.itemText) {
            return
        }
        this.setData({
            /*list: this.data.list.concat({
                id: Date.now(),
                text: this.data.itemText
            }),*/
            list: [...this.data.list, {
                id: Date.now(),
                text: this.data.itemText
            }],
            itemText: ''
        })

    },
    /*
    handleChange(event) { // 手动实现双向数据绑定
        this.setData({
            itemText: event.detail.value
        })
    }*/
})